﻿@{
    ViewBag.Title = "OperatorClassDetail";
    Layout = "~/Views/Shared/_ScheduleClass_View.cshtml";
}


@using ClassModel
@using ClassBLL
@using ClassCommon
@using System.Data
@using System.Data.SqlClient

@{
    t_classDemo_UserInfo currentLoginer = ViewBag.CurrentUser;
    t_class_task task = ViewBag.Task;
    // 根据任务获取是否已经上传了Excel表格
    t_class_fileupload excelFile = t_class_user_fileupalod_BLL.GetExcelFileWithTaskId(task.Id, currentLoginer.id);


    t_class_sections section = t_class_sections_BLL.GetSectionByTaskID(task.Id);
}

@section headerPartial {


    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
}


<div id="divbody" style="min-height: 495px;">
    <div class="container" id="divcon">

        <link rel="stylesheet" type="text/css" href="/Static/Template/css/webuploader.css">
        <link href="/Static/Template/css/baseInfo.css" rel="stylesheet" type="text/css">
        <link href="/Static/Template/css/jquery-ui.css" rel="stylesheet">
        <link href="/Static/Template/css/step-box.css" rel="stylesheet">

        <style>
            .info-edit-teacher-table td {
                padding: 1px 5px;
                font-size: 13px;
            }

                .info-edit-teacher-table td input {
                    width: 100px;
                    font-size: 13px;
                }
        </style>
        <style>
            a.view-course-plan {
                padding-left: 25px;
                background-repeat: no-repeat;
                margin-left: 10px;
                text-decoration: none;
                padding-bottom: 5px;
            }



            li.pos {
                margin-left: 15px;
            }

            .list-inline a {
                text-decoration: none;
                padding-left: 25px;
                padding-bottom: 5px;
            }
        </style>
        <div class="row" style="margin-top: 20px;">
            <div class="col-md-8">
                <ul class="list-inline">
                    <li>
                        <a href="javascript:void()" id="baseInfo" onclick="goUrl(OperatorClassDetail?id=@ViewBag.taskId)" class="task-baseInfo active task-baseInfo-active">基础信息</a>
                    </li>
                    <li class="pos">
                        <a href="ruleIndex?taskid=@(ViewBag.taskId)" id="rule" class="task-rule">规则条件</a>
                    </li>
                    <li class="pos">
                        <a href="BeginSchedule?taskid=@(ViewBag.taskId)" id="auto" class="task-auto">开始排课</a>
                    </li>

                </ul>
            </div>

            <div class="col-md-2 col-md-offset-2">
                <div class="dropdown" style="float: right;">
                    <button id="btnQuestions" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-default dropdown-toggle">
                        排课遇到难题
                           
                        <span class="caret"></span>
                    </button>
                    <ul id="questions-list" class="dropdown-menu dropdown-menu-right" aria-labelledby="btnQuestions">
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3722&amp;extra=page%3D1" target="_blank">云校排课支持导入其他排课软件的信息表格吗？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3721&amp;extra=page%3D1" target="_blank">如果学校是大周上课，每个大周时间超过7天怎么办？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3720&amp;extra=page%3D1" target="_blank">“基础信息”里的表格是否都需要导入？“导入课程表”有什么作用？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3717&amp;extra=page%3D1%26filter%3Dtypeid%26typeid%3D9"
                                target="_blank">已导入模板可以在线直接编辑吗？如果出现老师更换，怎么操作？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3719&amp;extra=page%3D1%26filter%3Dtypeid%26typeid%3D9"
                                target="_blank">导入数据时出现“上传数据格式不正确”或“上传数据失败”怎么办？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3264&amp;extra=page%3D2%26filter%3Dtypeid%26typeid%3D9"
                                target="_blank">早晚自习如何排？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3656&amp;extra=page%3D1%26filter%3Dtypeid%26typeid%3D9"
                                target="_blank">某门课单双周课时数不同怎么排？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=2808&amp;extra=page%3D1%26filter%3Dtypeid%26typeid%3D9"
                                target="_blank">单双周课怎么排？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3718&amp;extra=page%3D1" target="_blank">对于一门课有多个教师同时上课，在数据模板里怎么体现？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3723&amp;extra=page%3D1" target="_blank">模板课时信息中，“M+N”（如4+1）表示什么意思？如果学校所有的课都不连堂（单堂），在模板中应该如何填写？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3716&amp;extra=page%3D1%26filter%3Dtypeid%26typeid%3D9"
                                target="_blank">对于多个年级同时排课，不同年级科目设置不同，没安排的科目怎么填写？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3715&amp;extra=page%3D1" target="_blank">支持中职或高职学校排课吗？数据模板如何设置？</a>
                        </li>
                        <li>
                            <a href="http://bbs.yunxiao.com/forum.php?mod=viewthread&amp;tid=3714&amp;page=1&amp;extra=#pid6447"
                                target="_blank">数据有什么格式要求？是否一定要按照模块格式填写？</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <script src="/Static/Template/js/course-plan.js" charset="utf-8"></script>
        <script>
            var coursePlanService = new CoursePlanService();
            var hasCoursePlan = 0;
            $(function () {
                initButton();
            })
            function initButton() {
                coursePlanService.hasCoursePlan(taskId, function (has) {
                    hasCoursePlan = has;
                    $("li[show-by-courseplan='1']").hide();
                    if (has == "1") {
                        $("li[show-by-courseplan='1']").show();
                    }
                })
            }
        </script>

        <script>
            function fillQuestion(list) {
                var html = new Array();
                for (var i = 0; i < list.length; i++) {
                    html.push("<li><a href='" + list[i].text + "' target='_blank'>" + list[i].title + "</a></li>");
                }
                $("#questions-list").html(html.join(""));
            }

            function getContentList(sign) {
                jQuery.ajax({
                    url: "/m/content?sign=" + sign,
                    type: "GET",
                    success: function (ret) {
                        if (ret) {
                            fillQuestion(ret);
                        } else {
                            $("#questions-list").html("<li><a href='http://bbs.yunxiao.com/forum.php?mod=forumdisplay&fid=36'" +
                                " target='_blank'>暂时没有内容，前往论坛</a></li>");
                        }
                    }
                })
            }
        </script>

        <div class="modal fade" id="clssInfoClassRoomInfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            ×
                           
                        </button>
                        <h4 class="modal-title" id="myModalLabel">班级教室
                        </h4>
                    </div>
                    <div class="modal-body" id="divClassRoomInfo">
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="spcialClassRoomInfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            ×
                           
                        </button>
                        <h4 class="modal-title" id="myModalLabel">专业教室
                        </h4>
                    </div>
                    <div class="modal-body" id="divSpecialClassInfo">
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">
                            <span aria-hidden="true">×</span>
                        </button>
                        <div class="modal-title" id="myModalLabel">
                            <b id="b_info"></b>
                        </div>
                    </div>
                    <div class="modal-body">

                        <div id="uploadInfo" class="alert alert-warning" style="width: 100%; display: none"></div>
                        <div id="thelist" class="uploader-list"></div>
                        <input id="uploadedFileName" type="hidden">

                        <div class="alert alert-warning" id="divPrompt">
                            排课必须的基础信息包括“年级”、“班级”、“课时分配”、“教师安排”、“教室安排”等，请按照 模板 填写并导入。
                           
                        </div>
                        <img id="imgexample" src="/Static/Template/js/classroom.png" style="width: 568px; height: 150px;">
                    </div>
                    <div class="modal-footer">
                        <div id="uploader" style="display: inline-block">
                            <a class="btn btn-primary btn-md" id="picker">
                                <i class="glyphicon glyphicon-upload"></i>导入数据
                            </a>
                        </div>
                        <div style="display: inline-block">
                            <a class="btn btn-info btn-md" data-dismiss="modal">
                                <i class="glyphicon glyphicon-remove"></i>关闭
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 节次设置 -->

        <div class="modal fade" id="myModalJieCi" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false"
            data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content" id="modal1">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">
                            <span aria-hidden="true">×</span>
                        </button>
                        <div class="modal-title" id="myModalLabel">
                            <b>设置上课时间
                                   
                                <label style="color: red">(*修改后,设置的规则和预排会跟着进行相对变化！)</label>
                            </b>
                        </div>
                    </div>
                    <div class="modal-body" style="padding-top: 8px;">

                        <form class="form-horizontal" role="form">
                            <div style="margin-bottom: 10px; color: #ff0000">请对以下选项进行选择设置</div>
                            <div class="form-group">
                                <label for="txtName" class="col-sm-2 control-label">每周</label>

                                <div class="col-sm-9">
                                    <select class="form-control" id="daysPerWeek">
                                        <option value="1">1天</option>
                                        <option value="2">2天</option>
                                        <option value="3">3天</option>
                                        <option value="4">4天</option>
                                        <option selected="" value="5">5天</option>
                                        <option value="6">6天</option>
                                        <option value="7">7天</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="txtPeriod" class="col-sm-2 control-label">上午</label>

                                <div class="col-sm-9">
                                    <select class="form-control" id="amLessonCount">
                                        <option value="0">0节</option>
                                        <option value="1">1节</option>
                                        <option value="2">2节</option>
                                        <option value="3">3节</option>
                                        <option selected="" value="4">4节</option>
                                        <option value="5">5节</option>
                                        <option value="6">6节</option>
                                        <option value="7">7节</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="txtPeriod" class="col-sm-2 control-label">下午</label>

                                <div class="col-sm-9">
                                    <select class="form-control" id="pmLessonCount">
                                        <option value="0">0节</option>
                                        <option value="1">1节</option>
                                        <option value="2">2节</option>
                                        <option selected="" value="3">3节</option>
                                        <option value="4">4节</option>
                                        <option value="5">5节</option>
                                        <option value="6">6节</option>
                                        <option value="7">7节</option>
                                    </select>
                                </div>
                            </div>
                            @* <div class="form-group">
                                <label for="txtPeriod" class="col-sm-2 control-label">晚上</label>

                                <div class="col-sm-9">
                                    <select class="form-control" id="eveLessonCount">
                                        <option selected="" value="0">0节</option>
                                        <option value="1">1节</option>
                                        <option value="2">2节</option>
                                        <option value="3">3节</option>
                                        <option value="4">4节</option>
                                        <option value="5">5节</option>
                                        <option value="6">6节</option>
                                        <option value="7">7节</option>
                                    </select>
                                </div>
                            </div>*@
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" onclick="saveClassJieCiInfo()">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="tabbable">
            <!-- Only required for left/right tabs -->
            <div style="margin-top: 20px">
                <style type="text/css">
                    .my-list-inline {
                        padding-left: 0;
                        list-style: none;
                    }

                        .my-list-inline > li {
                            display: inline-block;
                            width: 110px;
                            text-align: center;
                            margin-left: -4px;
                            cursor: pointer;
                        }

                            .my-list-inline > li:first-child {
                                margin-left: 0px;
                            }

                        .my-list-inline .active {
                            color: #ec5d41;
                            border-bottom: 4px solid #ec5d41;
                            cursor: default;
                        }

                        .my-list-inline a {
                            color: #666666;
                            font-size: 15px;
                            text-decoration: none;
                        }

                    a.colorful {
                        color: #ec5d41;
                    }
                </style>

                <div class="row">
                    <div class="col-md-8" style="width: 100%;">
                        <ul class="my-list-inline" id="ulTab">
                            <li id="li0" style="width: 150px" class="active">
                                <a tabindex="0" href="http://paike.yunxiao.com/m/baseInfo/index?taskId=2640188197994496#tab1"
                                    data-toggle="tab" onclick="switchTab(this)" class="colorful">任课信息</a>
                            </li>
                            @* <li id="li2">
                                <a tabindex="2" href="http://paike.yunxiao.com/m/baseInfo/index?taskId=2640188197994496#tab3"
                                    data-toggle="tab" onclick="switchTab(this)">教室管理 </a>
                            </li>*@
                            @* <li id="li4">
                                <a tabindex="4" href="http://paike.yunxiao.com/m/baseInfo/index?taskId=2640188197994496#tab5"
                                    data-toggle="tab" onclick="switchTab(this)">导入课程表</a>
                            </li>*@
                            @* <li id="li6">
                                <a tabindex="6" href="http://paike.yunxiao.com/m/baseInfo/index?taskId=2640188197994496#tab_info_edit"
                                    data-toggle="tab" onclick="switchTab(this)">信息维护</a>
                            </li>*@

                            @if (section == null)
                            { 
                            
                            
                                <li id="li5">
                                    <a tabindex="0" href="javascript:void(0);"
                                        data-toggle="tab" onclick="showTimeTableModal(this)">
                                        <span class="glyphicon glyphicon-time" style="color: #32ABF7;"></span>节次设置</a>
                                </li>
                            }

                        </ul>
                    </div>
                </div>
                <div style="width: 580px; margin-top: -10px; border-top: 1px solid #b3b3b3"></div>
                <script>
                    var _hmt = _hmt || [];
                    (function () {
                        var hm = document.createElement("script");
                        hm.src = "https://hm.baidu.com/hm.js?7c66c07d4e8cc54deba8d7f967efe75b";
                        var s = document.getElementsByTagName("script")[0];
                        s.parentNode.insertBefore(hm, s);
                    })();
                </script>
            </div>
            <div class="tab-content">
                <div class="tab-pane active" id="tab1">
                    <div class="row">
                        <div class="col-md-7 text-info">
                            请按照模板样式填写课时分配和任课安排,注意阅读红色标注<br />
                            @if (section != null)
                            { 
                                <div style="margin-bottom: 10px; color: #37abf1">您已经设置节次信息。【上午@(section.AMSections)节】  【下午@(section.PMSections)节】 【一周@(section.dayOfWeek)天】</div>
                            }

                        </div>
                        <div class="col-md-5">
                            <ul class="list-unstyled list-inline">
                                <li>
                                    <button class="btn btn-primary btn-md" name="btnUp">
                                        <span class="glyphicon glyphicon-upload"></span>点击上传
                                       
                                    </button>
                                </li>
                                <li>
                                    <button class="btn btn-primary btn-md" onclick="donwloadTmp();">
                                        <span class="glyphicon glyphicon-download"></span>下载课表Excel表格模板
                                       
                                    </button>
                                </li>
                                <li class="export" style="display: none">
                                    <button class="btn btn-primary btn-md export" onclick="downloadBaseInfo()">
                                        <span class="glyphicon glyphicon-export"></span>导出
                                       
                                    </button>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <table name="tblImpt1" style="width: 100%; float: left; display: none;">
                        <tbody>
                            <tr>
                                <td style="text-align: center">
                                    <span style="font-weight: bold;">课时及教师分配信息</span>
                                </td>
                            </tr>
                        </tbody>
                    </table>

                    <!-- 展示用户 excel表格 -->
                    <div id="p1" class="content" style="padding-top: 10px;">
                        @if (excelFile == null)
                        { 
                            <table name="tblInfo1" class="tableinfo" style="display: inline-table;">
                                <tbody>
                                    <tr>
                                        <td style="border: 1px solid #eee; padding: 20px 2px;">
                                            <img src="/Static/Template/image/baseinfo.jpg" style="width: 950px">
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        }
                        else
                        {
                            // 文件路径
                            string filePath = HttpContext.Current.Server.MapPath(excelFile.savePath);
                            ExcelHelper eh = new ExcelHelper(filePath);

                            System.Data.DataTable dt = eh.ExcelToDataTable("Sheet1", true);

                            // 列拼接
                            System.Text.StringBuilder colsBuilder = new System.Text.StringBuilder();
                            colsBuilder.AppendLine("<tr>");

                            for (int c = 0; c < dt.Columns.Count; c++)
                            {
                                string columnName = dt.Columns[c].ColumnName;
                                if (columnName.Contains("Column")) { columnName = ""; }
                                colsBuilder.AppendLine(string.Format("<td>{0}</td>", columnName));
                            }

                            colsBuilder.AppendFormat("</tr>");


                            // 行拼接
                            System.Text.StringBuilder rowsBuilder = new System.Text.StringBuilder();
                            foreach (DataRow row in dt.Rows)
                            {
                                rowsBuilder.AppendLine("<tr style=\"background-color: rgb(255, 255, 255);\">");

                                for (int colIndex = 0; colIndex < dt.Columns.Count; colIndex++)
                                {
                                    rowsBuilder.AppendLine(string.Format("<td>{0}</td>", row[colIndex].ToString()));
                                }

                                rowsBuilder.AppendLine("</tr>");
                            }
              
                            <table class="info" id="tblClass">
                                <tbody>
                                    <!-- 表头 -->
                                    @Html.Raw(colsBuilder.ToString())
                                    <!-- 内容 -->
                                    @Html.Raw(rowsBuilder.ToString())

                                </tbody>
                            </table>
                        }


                    </div>
                </div>
                <input type="hidden" id="input3" value="0">
                <div class="tab-pane" id="tab3">
                    <table name="tblImpt3" style="width: 100%; float: left; display: none;">
                        <tbody>
                            <tr>
                                <td style="text-align: center">
                                    <span style="font-weight: bold; margin-left: 90px;">专业教室信息</span>
                                </td>
                            </tr>
                        </tbody>
                    </table>

                    <div id="p3" class="content">
                        <table name="tblInfo3" class="tableinfo">
                            <tbody>
                                <tr>
                                    <td>请先上传任课信息
                                           
                                        <!--<img src="/static/img/classroom.jpg" style="width: 600px;height: 250px">-->
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                </div>
                <div class="tab-pane" id="tab5">
                    <div class="row">
                        <div class="col-md-8 text-info">请按照模板样式填写课时分配和任课安排,注意阅读红色标注</div>
                        <div class="col-md-4">
                            <ul class="list-unstyled list-inline">
                                <li>
                                    <button class="btn btn-primary btn-md" name="btnUp">
                                        <span class="glyphicon glyphicon-upload"></span>点击上传
                                       
                                    </button>
                                </li>
                                <li>
                                    <button class="btn btn-primary btn-md" onclick="goUrl(&#39;/m/baseInfo/getAllCoursePlan&#39;);">
                                        <span class="glyphicon glyphicon-download"></span>下载模板
                                       
                                    </button>
                                </li>
                                <li>
                                    <button class="btn btn-primary btn-md export" onclick="downloadCourseInfo()">
                                        <span class="glyphicon glyphicon-export"></span>导出
                                       
                                    </button>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <table name="tblImpt5" style="width: 100%; float: left; display: none">
                        <tbody>
                            <tr>
                                <td style="text-align: center">
                                    <span style="font-weight: bold; margin-left: 90px;">课程表信息</span>
                                </td>
                            </tr>
                        </tbody>
                    </table>

                    <div id="p5" class="content">
                        <table name="tblInfo5" class="tableinfo" style="display: inline-table">
                            <tbody>
                                <tr>
                                    <td style="text-align: center">
                                        <img src="/Static/Template/image/courseplans.jpg" style="width: 950px">
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                </div>
                <div class="tab-pane" id="tab6">
                    <div id="p6" class="content">
                    </div>
                </div>

                <!--tab_info_edit-->
                <div class="tab-pane" id="tab_info_edit">
                    <div id="info_edit" class="content" style="padding-top: 10px">
                        <div style="font-weight: bold; margin-bottom: 10px">老师信息</div>
                        <table class="info-edit-teacher-table"></table>
                    </div>
                </div>
            </div>

            <div class="row"></div>

            <div id="stepArea" style="height: 70px;">
                <div id="stepBox" class="text-right stepBoxFixed2" style="bottom: 0px;">
                    <button type="button" class="btn btn-primary btn-sm" data-id="" id="btnNext" onclick="nextStep(this);">
                        下一步
                    </button>
                </div>
            </div>
        </div>
        <input type="hidden" id="taskId" />
        <script type="text/javascript">
            var taskId = "2640188197994496";
            var hasSetTimetableStructure = 1;
        </script>
        <script src="/Static/Template/js/base-info.js" type="text/javascript"></script>
        <script src="/Static/Template/js/jquery-ui.js"></script>
        <script type="text/javascript" src="/Static/Template/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="/Static/Template/js/webuploader.js"></script>
        <script type="text/javascript" src="/Static/Template/js/fileupload.js"></script>

        <script src="/Static/Template/js/teacher.js" type="text/javascript"></script>
        <script src="/Static/Template/js/index.js" type="text/javascript"></script>
        <script src="/Static/Template/js/fix-table.js" type="text/javascript"></script>
        <script type="text/javascript" src="/Static/Template/js/step-box.js"></script>
        <script type="text/javascript" src="/Static/Template/js/hover.js"></script>
        <script src="/Static/Template/js/info-edit.js"></script>


        <script>
            stepBox.init();
            $(function () {
                $(".dropdown-toggle").dropdown();
                getContentList("qBaseinfo");
            })
        </script>


    </div>
</div>


@section scripts {

    <script type="text/javascript">
        // 下载课表模板
        function donwloadTmp() {
            window.open("/Static/示例数据-任课-课时.xls");
        }


        function getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) { return pair[1]; }
            }
            return (false);
        }

        // 获取taskID
        (function () {
            $("#taskId").val(getQueryVariable("id"));
            $("#btnNext").attr("data-id", getQueryVariable("id"));
        })();


        var dataId = $("#btnNext").attr("data-id");

        // 下一步
        function nextStep(obj) {
            // 检查当前用户的当前excel文件是否设置了节次。
            var $this = $(obj);
            $.get("CheckSectionIsExist", { taskid: $this.attr("data-id") }, function (data) {
                // console.log(data);
                if (!data.status) {
                    // 弹出节次设置的弹窗
                    $("#li5 a").click();
                } else {
                    window.location.href = "ruleIndex?taskid=" + $this.attr("data-id");
                }
            });
        }


        function saveClassJieCiInfo() {
            var daysPerWeek = $("#daysPerWeek").find("option:selected").val();
            var amLessonCount = $("#amLessonCount").find("option:selected").val();
            var pmLessonCount = $("#pmLessonCount").find("option:selected").val();

            // 提交节次信息
            $.post("SettingSection", {
                taskid: dataId,
                dayofweek: daysPerWeek,
                amSections: amLessonCount,
                pmSections: pmLessonCount
            }, function (data) {
                // console.log(data.status + ' -- ' + data.info);
                if (data.status) {
                    // 排课信息添加成功
                    // 
                    window.location.reload();
                } else {
                    alert(data.info);
                    if (data.info2) {

                        alert(data.info2);
                    }
                }
            });

        }


    </script>
}
